home *** CD-ROM | disk | FTP | other *** search
- ;-------------------------random routine begins--------------------------+
- ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
- ; page : 175
- ;
- ; NAME RANDOM
- ; ROUTINE FOR PSEUDO-RANDOM NUMBER GENERATOR
- ;
- ; FUNCTION: This routine generates pseudo-random numbers bewteen0 and 1.
- ; The numbers are stored in 16-bit binary fixed-point notation with the
- ; binary point on the extreme left.
- ; INPUT: Upon entry the variabl,e SEED contains a seed value.
- ; OUTPUT: Upon exit the seed is updated and the CX register contains a
- ; pseudo-random number.
- ; REGISTERS USED: Only CX is modified.
- ; SEGMENTS REFERENCED: pon entry the data segment contains the variable
- ; SEED.
- ; ROUTINES CALLED: None
- ; SPECIAL NOTES: None
- ;
- random proc far
- ;
- mov cx,seed ;get the seed
- add cx,9248h ; add random pattern
- ror cx,1 ; rotate
- ror cx,1 ; three
- ror cx,1 ; times.
- mov seed,cx ; put it back
- ret ; return
- ;
- random endp
- ;-------------------------random routine ends---------------------------+